package com.xjrsoft.module.customerTwo.aiplm.t_aiplm_model.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xjrsoft.core.tool.utils.StringUtil;
import com.xjrsoft.module.customerTwo.aiplm.t_aiplm_model.entity.TAiplmModel;
import com.xjrsoft.module.customerTwo.aiplm.t_aiplm_model.dto.TAiplmModelListDto;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xjrsoft.common.page.ConventPage;
import com.xjrsoft.common.page.PageOutput;
import java.util.List;
import com.xjrsoft.module.customerTwo.aiplm.t_aiplm_model.mapper.TAiplmModelMapper;
import com.xjrsoft.module.customerTwo.aiplm.t_aiplm_model.service.ITAiplmModelService;
import com.xjrsoft.core.mp.base.BaseService;
import com.xjrsoft.core.tool.utils.Func;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;

/**
 *  服务实现类
 *
 * @author dongxinhang
 * @since 2024-07-03
 */
@Service
@AllArgsConstructor
public class TAiplmModelServiceImpl extends BaseService<TAiplmModelMapper, TAiplmModel> implements ITAiplmModelService {


	@Override
	public IPage<TAiplmModel> getPageList(TAiplmModelListDto pageListDto) {
		Wrapper<TAiplmModel> wrapper = Wrappers.<TAiplmModel>query().lambda()
				.like(!StringUtil.isEmpty(pageListDto.getF_ModelNum()), TAiplmModel::getFModelnum, pageListDto.getF_ModelNum())
				.like(!StringUtil.isEmpty(pageListDto.getF_ModelName()), TAiplmModel::getFModelname, pageListDto.getF_ModelName())
				.eq(!StringUtil.isEmpty(pageListDto.getF_Enable()), TAiplmModel::getFEnable, pageListDto.getF_Enable());
		return this.page(ConventPage.getPage(pageListDto), wrapper);
	}

	@Override
	public boolean addTAiplmModel(TAiplmModel tAiplmModel) {
		boolean isSuccess = this.save(tAiplmModel);
		return isSuccess;
	}

	@Override
	public boolean updateTAiplmModel(String id, TAiplmModel tAiplmModel) {
		tAiplmModel.setFId(id);
		return this.updateById(tAiplmModel);
	}

	public boolean delete(String ids) {
		List<String> idList = Func.toStrList(ids);
		if (this.removeByIds(idList)) {
			return true;
		}
		return false;
	}

}